package c.c.b.a.b.a.k;

import c.b.a.a.a;
import com.huawei.hms.analytics.core.crypto.AesCipher.AesLen;
import javax.security.auth.x500.X500Principal;

/* compiled from: DistinguishedNameParser */
public final class d {
    public final String a;
    public final int b;
    public int c;
    public int d;
    public int e;
    public int f;
    public char[] g;

    public d(X500Principal x500Principal) {
        String name = x500Principal.getName("RFC2253");
        this.a = name;
        this.b = name.length();
    }

    public final int a(int i) {
        int i2 = i + 1;
        String str = "Malformed DN: ";
        StringBuilder g;
        if (i2 < this.b) {
            char[] cArr = this.g;
            char c = cArr[i];
            if (c >= '0' && c <= '9') {
                i = c - 48;
            } else if (c >= 'a' && c <= 'f') {
                i = c - 87;
            } else if (c < 'A' || c > 'F') {
                g = a.g(str);
                g.append(this.a);
                throw new IllegalStateException(g.toString());
            } else {
                i = c - 55;
            }
            char c2 = cArr[i2];
            if (c2 >= '0' && c2 <= '9') {
                i2 = c2 - 48;
            } else if (c2 >= 'a' && c2 <= 'f') {
                i2 = c2 - 87;
            } else if (c2 < 'A' || c2 > 'F') {
                g = a.g(str);
                g.append(this.a);
                throw new IllegalStateException(g.toString());
            } else {
                i2 = c2 - 55;
            }
            return (i << 4) + i2;
        }
        g = a.g(str);
        g.append(this.a);
        throw new IllegalStateException(g.toString());
    }

    /* JADX WARNING: Removed duplicated region for block: B:8:0x0017  */
    /* JADX WARNING: Removed duplicated region for block: B:6:0x0015  */
    public final java.lang.String b() {
        /*
        r7 = this;
    L_0x0000:
        r0 = r7.c;
        r1 = r7.b;
        r2 = 32;
        if (r0 >= r1) goto L_0x0013;
    L_0x0008:
        r3 = r7.g;
        r3 = r3[r0];
        if (r3 != r2) goto L_0x0013;
    L_0x000e:
        r0 = r0 + 1;
        r7.c = r0;
        goto L_0x0000;
    L_0x0013:
        if (r0 != r1) goto L_0x0017;
    L_0x0015:
        r0 = 0;
        return r0;
    L_0x0017:
        r7.d = r0;
        r0 = r0 + 1;
        r7.c = r0;
    L_0x001d:
        r0 = r7.c;
        r1 = r7.b;
        r3 = 61;
        if (r0 >= r1) goto L_0x0034;
    L_0x0025:
        r4 = r7.g;
        r5 = r4[r0];
        if (r5 == r3) goto L_0x0034;
    L_0x002b:
        r4 = r4[r0];
        if (r4 == r2) goto L_0x0034;
    L_0x002f:
        r0 = r0 + 1;
        r7.c = r0;
        goto L_0x001d;
    L_0x0034:
        r4 = "Unexpected end of DN: ";
        if (r0 >= r1) goto L_0x00d6;
    L_0x0038:
        r7.e = r0;
        r1 = r7.g;
        r0 = r1[r0];
        if (r0 != r2) goto L_0x0071;
    L_0x0040:
        r0 = r7.c;
        r1 = r7.b;
        if (r0 >= r1) goto L_0x0055;
    L_0x0046:
        r5 = r7.g;
        r6 = r5[r0];
        if (r6 == r3) goto L_0x0055;
    L_0x004c:
        r5 = r5[r0];
        if (r5 != r2) goto L_0x0055;
    L_0x0050:
        r0 = r0 + 1;
        r7.c = r0;
        goto L_0x0040;
    L_0x0055:
        r5 = r7.g;
        r5 = r5[r0];
        if (r5 != r3) goto L_0x005e;
    L_0x005b:
        if (r0 == r1) goto L_0x005e;
    L_0x005d:
        goto L_0x0071;
    L_0x005e:
        r0 = new java.lang.IllegalStateException;
        r1 = c.b.a.a.a.g(r4);
        r2 = r7.a;
        r1.append(r2);
        r1 = r1.toString();
        r0.<init>(r1);
        throw r0;
    L_0x0071:
        r0 = r7.c;
        r0 = r0 + 1;
        r7.c = r0;
    L_0x0077:
        r0 = r7.c;
        r1 = r7.b;
        if (r0 >= r1) goto L_0x0088;
    L_0x007d:
        r1 = r7.g;
        r1 = r1[r0];
        if (r1 != r2) goto L_0x0088;
    L_0x0083:
        r0 = r0 + 1;
        r7.c = r0;
        goto L_0x0077;
    L_0x0088:
        r0 = r7.e;
        r1 = r7.d;
        r0 = r0 - r1;
        r2 = 4;
        if (r0 <= r2) goto L_0x00c9;
    L_0x0090:
        r0 = r7.g;
        r3 = r1 + 3;
        r3 = r0[r3];
        r4 = 46;
        if (r3 != r4) goto L_0x00c9;
    L_0x009a:
        r3 = r0[r1];
        r4 = 79;
        if (r3 == r4) goto L_0x00a6;
    L_0x00a0:
        r3 = r0[r1];
        r4 = 111; // 0x6f float:1.56E-43 double:5.5E-322;
        if (r3 != r4) goto L_0x00c9;
    L_0x00a6:
        r3 = r1 + 1;
        r3 = r0[r3];
        r4 = 73;
        if (r3 == r4) goto L_0x00b6;
    L_0x00ae:
        r3 = r1 + 1;
        r3 = r0[r3];
        r4 = 105; // 0x69 float:1.47E-43 double:5.2E-322;
        if (r3 != r4) goto L_0x00c9;
    L_0x00b6:
        r3 = r1 + 2;
        r3 = r0[r3];
        r4 = 68;
        if (r3 == r4) goto L_0x00c6;
    L_0x00be:
        r3 = r1 + 2;
        r0 = r0[r3];
        r3 = 100;
        if (r0 != r3) goto L_0x00c9;
    L_0x00c6:
        r1 = r1 + r2;
        r7.d = r1;
    L_0x00c9:
        r0 = new java.lang.String;
        r1 = r7.g;
        r2 = r7.d;
        r3 = r7.e;
        r3 = r3 - r2;
        r0.<init>(r1, r2, r3);
        return r0;
    L_0x00d6:
        r0 = new java.lang.IllegalStateException;
        r1 = c.b.a.a.a.g(r4);
        r2 = r7.a;
        r1.append(r2);
        r1 = r1.toString();
        r0.<init>(r1);
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.b.a.b.a.k.d.b():java.lang.String");
    }

    public final char c() {
        int i = this.c + 1;
        this.c = i;
        if (i != this.b) {
            char[] cArr = this.g;
            char c = cArr[i];
            if (!(c == ' ' || c == '%' || c == '\\' || c == '_' || c == '\"' || c == '#')) {
                switch (c) {
                    case '*':
                    case '+':
                    case ',':
                        break;
                    default:
                        switch (c) {
                            case ';':
                            case '<':
                            case '=':
                            case '>':
                                break;
                            default:
                                i = a(i);
                                this.c++;
                                c = '?';
                                if (i >= AesLen.ROOTKEY_COMPONET_LEN) {
                                    if (i >= 192 && i <= 247) {
                                        int i2;
                                        if (i <= 223) {
                                            i &= 31;
                                            i2 = 1;
                                        } else if (i <= 239) {
                                            i2 = 2;
                                            i &= 15;
                                        } else {
                                            i2 = 3;
                                            i &= 7;
                                        }
                                        int i3 = 0;
                                        while (i3 < i2) {
                                            int i4 = this.c + 1;
                                            this.c = i4;
                                            if (i4 != this.b && this.g[i4] == '\\') {
                                                i4++;
                                                this.c = i4;
                                                i4 = a(i4);
                                                this.c++;
                                                if ((i4 & 192) == AesLen.ROOTKEY_COMPONET_LEN) {
                                                    i = (i << 6) + (i4 & 63);
                                                    i3++;
                                                }
                                            }
                                        }
                                    }
                                    return c;
                                }
                                c = (char) i;
                                return c;
                        }
                }
            }
            return cArr[i];
        }
        StringBuilder g = a.g("Unexpected end of DN: ");
        g.append(this.a);
        throw new IllegalStateException(g.toString());
    }
}
